<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Inv_receive extends CI_Controller {

	public function __construct(){
		parent::__construct();
		$this->load->model('wus');
		$this->load->model($this->session->userdata('formodel'));
		$this->load->library('variable');
	}

	public function index(){

	  $this->load->view('layouts/header',$this->variable->load_data($this->session->userdata('title')));
	  $this->load->view($this->session->userdata('formain'));
	  $this->load->view('layouts/footer');
	}
	public function add_form(){
				$this->load->view($this->session->userdata('foradd'),array(
					'items'		=> $this->inv_receive_model->get_items(),
					'subs'		=> $this->inv_receive_model->get_sub_inv()
					));
	}
	public function edit_form($id){

			$this->load->view($this->session->userdata('foredit'),array(
				));
		
	}
	public function view_form($id){
			$this->load->view($this->session->userdata('forview'),array(
					'items'		=> $this->inv_receive_model->get_items(),
					'subs'		=> $this->inv_receive_model->get_sub_inv(),
					'datus'		=> $this->inv_receive_model->get_trans_data($id)
				));
	}


	public function search_locators(){
		$query = $this->inv_receive_model->get_locators($this->input->post('sub_ids'));
		echo json_encode($query);
	}
	 
	 public function insert_trans_inv(){
	 	$data = array(
	 			':p_item_id'		=> $this->input->post('tr_item_id'),
	 			':p_sub_id'			=> $this->input->post('trans_sub_id'),
	 			':p_locator_id'		=> $this->input->post('trans_locate_id'),
	 			':p_item_qty'		=> $this->input->post('trans_item_qty'),
	 			':p_reorder_lvl'	=> $this->input->post('trans_item_RL'),
	 			':p_user_id'		=> $this->session->userdata('user_id')
	 		);

	 	$this->inv_receive_model->insert_trans_inv($data);
	 }

	 public function search_transInv(){
	 	$query = $this->inv_receive_model->search_trans($this->input->post('trans_item_num'));
	 	if(!empty($query)) {
			echo json_encode($query);
			}else{
				echo json_encode("none");
		}
	 }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */